#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 3e5 + 5;

int n, m;
struct Node {
  int val, tag;
  int fa, ch[2], dis;
} tr[N];
#define val(p) tr[p].val
#define tag(p) tr[p].tag
#define fa(p) tr[p].fa
#define lc(p) tr[p].ch[0]
#define rc(p) tr[p].ch[1]
#define dis(p) tr[p].dis
int d0;
multiset<int> mx;
int st[N], top;
void erase(int x) { mx.erase(mx.find(val(x))); }
void insert(int x) { mx.insert(val(x)); }
int find(int x) {
  while (fa(x)) x = fa(x);
  return x;
}
void addtag(int x, int v) {
  if (x) val(x) += v, tag(x) += v;
}
void pushup(int x) {
  if (dis(lc(x)) < dis(rc(x))) swap(lc(x), rc(x));
  dis(x) = dis(rc(x)) + 1;
}
void pushdown(int x) {
  if (tag(x)) {
    addtag(lc(x), tag(x));
    addtag(rc(x), tag(x));
    tag(x) = 0;
  }
}
int merge(int x, int y) {
  if (!x || !y) return x + y;
  if (val(x) < val(y)) swap(x, y);
  pushdown(x);
  rc(x) = merge(rc(x), y);
  if (rc(x)) fa(rc(x)) = x;
  pushup(x);
  return x;
}
void pushdown_all(int x) {
  top = 0;
  while (x) st[++top] = x, x = fa(x);
  while (top) pushdown(st[top--]);
}
int del(int x) {
  pushdown_all(x);
  int y = fa(x);
  int z = merge(lc(x), rc(x));
  if (z) fa(z) = y;
  if (y) tr[y].ch[rc(y) == x] = z;
  while (y) {
    pushup(y);
    z = y, y = fa(y);
  }
  fa(x) = lc(x) = rc(x) = dis(x) = 0;
  return z;
}
void add(int x, int v) {
  pushdown_all(x);
  erase(find(x));
  int y = del(x);
  val(x) += v;
  int rt = merge(x, y);
  insert(rt);
}
void add_all(int x, int v) {
  x = find(x);
  erase(x);
  addtag(x, v);
  insert(x);
}
void solve() {
  dis(0) = -1;
  cin >> n;
  rep(i, 1, n) {
    cin >> val(i);
    insert(i);
  }
  cin >> m;
  while (m--) {
    string op;
    int x, y;
    cin >> op;
    if (op == "U" || op == "A1" || op == "A2")
      cin >> x >> y;
    else if (op != "F3")
      cin >> x;
    if (op == "U") {
      x = find(x), y = find(y);
      if (x == y) continue;
      erase(x), erase(y);
      int t = merge(x, y);
      insert(t);
    }
    if (op == "A1") add(x, y);
    if (op == "A2") add_all(x, y);
    if (op == "A3") d0 += x;
    if (op == "F1") pushdown_all(x), cout << d0 + val(x) << endl;
    if (op == "F2") x = find(x), cout << d0 + val(x) << endl;
    if (op == "F3") cout << d0 + *mx.rbegin() << endl;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  // freopen("P3273_1.in", "r", stdin);
  // freopen("1.out", "w", stdout);
  solve();
  return 0;
}